﻿package Graficos 
{
	
	import flash.display.*;
	import flash.events.*;
	
	public class Flare 
	{
		protected var x:int = 200;
		protected var y:int = 200;
		protected var z:int = 100 ;
		
		protected var bitmap:Bitmap;
		
		private var intensidad:Number;
		private var colorRGB:uint;
		
		public function Flare (i:Number,color:uint)
		{
			intensidad = i;
			bitmap = new Bitmap(new BitmapData(10,10,false,color));
			bitmap.addEventListener(Event.ENTER_FRAME,animar);
		}
		
		public function agregarEscenario(unEscenario:Sprite)
		{
			unEscenario.addChild(bitmap);
		}
		
		public function animar (e:Event)
		{
			bitmap.x = x;
			bitmap.y = y;
			//bitmap.x++;			
		}
		
		public function getVectorLuzNormalizado (xx:Number, yy:Number, zz:Number):Punto3d
		{
			var pRet:Punto3d = new Punto3d(x-xx,y-yy,z-zz);
			var modulo:Number = Math.sqrt(pRet.distanciaCuadrada());
			pRet.x = 127*pRet.x / modulo;
			pRet.y = 127*pRet.y / modulo;
			pRet.z = 127*pRet.z / modulo;
			return pRet;
		}
		
		public function setCoords (xx:Number, yy:Number)
		{
			x=xx;
			y=yy;
		}
		
		public function position ():Punto3d
		{
			return new Punto3d (x,y,z);
		}
		
	}
	
}